package com.triones.api.controller.web;

import cn.dev33.satoken.annotation.SaCheckPermission;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.PageQuery;
import com.ruoyi.common.core.domain.R;
import com.ruoyi.common.core.page.TableDataInfo;
import com.triones.api.entity.KycVerifyDO;
import com.triones.api.entity.param.KycVerifyParams;
import com.triones.api.entity.vo.KycVerifyVO;
import com.triones.api.service.KycVerifyService;
import lombok.RequiredArgsConstructor;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

/**
 * kyc管理
 */
@Validated
@RequiredArgsConstructor
@RestController
@RequestMapping("/system/kyc")
public class KycVerifyController extends BaseController {

    private final KycVerifyService kycVerifyService;

    /**
     * kyc列表（分页）
     */
    @SaCheckPermission("system:kycList:list")
    @GetMapping("/pageList")
    public TableDataInfo<KycVerifyVO> pageList(KycVerifyParams kycVerifyParams, PageQuery pageQuery) {
        return kycVerifyService.pageList(kycVerifyParams, pageQuery);
    }

    /**
     * kyc申请列表（分页）
     */
    @SaCheckPermission("system:kycApply:list")
    @GetMapping("/applyList")
    public TableDataInfo<KycVerifyVO> applyListPageList(KycVerifyParams params, PageQuery pageQuery) {
        return kycVerifyService.pageList(params, pageQuery);
    }

    /**
     * 审核
     */
    @SaCheckPermission("system:kycApply:edit")
    @PutMapping("/audit")
    public R<Void> audit(@RequestBody KycVerifyDO dto) {
        return toAjax(kycVerifyService.audit(dto));
    }

    /**
     * kyc详情
     */
    @SaCheckPermission("system:kycApply:query")
    @GetMapping("/{id}")
    public R<KycVerifyVO> getInfo(@PathVariable Long id) {
        return R.ok(kycVerifyService.getInfo(id));
    }
}
